package cn.iocoder.yudao.module.book.dal.mysql.collections;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;

import cn.iocoder.yudao.module.book.controller.app.booksShell.vo.AppCollectionsRespVO;
import cn.iocoder.yudao.module.book.dal.dataobject.collections.CollectionsDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.book.controller.admin.collections.vo.*;
import org.apache.ibatis.annotations.Param;

/**
 * 绘本集 Mapper
 *
 * @author xi
 */
@Mapper
public interface CollectionsMapper extends BaseMapperX<CollectionsDO> {

    default PageResult<CollectionsDO> selectPage(CollectionsPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<CollectionsDO>()
                .eqIfPresent(CollectionsDO::getCollectionId, reqVO.getCollectionId())
                .eqIfPresent(CollectionsDO::getTitle, reqVO.getTitle())
                .eqIfPresent(CollectionsDO::getImage, reqVO.getImage())
                .likeIfPresent(CollectionsDO::getDescription, reqVO.getDescription())
                .eqIfPresent(CollectionsDO::getCategoryId, reqVO.getCategoryId())
                .eqIfPresent(CollectionsDO::getIsEnglish, reqVO.getIsEnglish())
                .eqIfPresent(CollectionsDO::getIsTop, reqVO.getIsTop())
                .betweenIfPresent(CollectionsDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(CollectionsDO::getCollectionId));
    }

    AppCollectionsRespVO selectByLang(@Param("collectionId") Integer collectionId,@Param("lang") Integer lang);

    int updateIsTop(@Param("id") Integer id);

    List<AppCollectionsRespVO> selectAll();

    List<AppCollectionsRespVO> selectAllByLang(Integer lang);

    Integer getCategoryId(@Param("id") Integer id);

    List<AppCollectionsRespVO> selectLikeContent(@Param("content") String content);
}